package org.jeecg.modules.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.system.entity.ZkEquipmentMaintain;
import org.jeecg.modules.system.entity.ZkEquipmentMaintainDetail;
import org.jeecg.modules.system.mapper.ZkEquipmentMaintainMapper;
import org.jeecg.modules.system.service.IZkEquipmentMaintainService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Description: 设备保养表
 * @Author: jeecg-boot
 * @Date:   2024-04-28
 * @Version: V1.0
 */
@Service
public class ZkEquipmentMaintainServiceImpl extends ServiceImpl<ZkEquipmentMaintainMapper, ZkEquipmentMaintain> implements IZkEquipmentMaintainService {

    //设备保养根据当前登录人员和时间查询

    @Override
    public List<ZkEquipmentMaintain> queryPageListVo(Integer pageNo, Integer pageSize) {

        //获取系统当前登录人
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        Page<ZkEquipmentMaintain> page = new Page<ZkEquipmentMaintain>(pageNo,pageSize);
        List<ZkEquipmentMaintain> list=this.baseMapper.queryPageListVo(page,sysUser.getId());
        return list;
    }

    /**
     * 审批界面/保养（根据当前登录人和状态分页查询）
     * @return
     */
    @Override
    public IPage<ZkEquipmentMaintainDetail> queryZkEquipmentMaintainDetail(Integer pageNo, Integer pageSize) {
        //获取系统当前登录人
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        Page<ZkEquipmentMaintainDetail> page = new Page<ZkEquipmentMaintainDetail>(pageNo,pageSize);

        return this.baseMapper.queryZkEquipmentMaintainDetail(page,sysUser.getId());
    }

    /**
     * 发起界面/保养（根据当前登录人和状态分页查询）
     * @return
     */
    @Override
    public IPage<ZkEquipmentMaintainDetail> queryZkEquipmentMaintainList(Integer pageNo, Integer pageSize) {
        //获取系统当前登录人
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        Page<ZkEquipmentMaintainDetail> page = new Page<ZkEquipmentMaintainDetail>(pageNo,pageSize);

        return this.baseMapper.queryZkEquipmentMaintainList(page,sysUser.getId());
    }

    /**
     * 抄送任务(保养)（根据当前登录人和状态将维修，保养，检修放在同一个分页查询中）
     * @return
     */
    @Override
    public IPage<ZkEquipmentMaintainDetail> queryZkEquipmentMaintainCc(Integer pageNo, Integer pageSize) {
        //获取系统当前登录人
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();

        Page<ZkEquipmentMaintainDetail> page = new Page<ZkEquipmentMaintainDetail>(pageNo,pageSize);

        return this.baseMapper.queryZkEquipmentMaintainCc(page,sysUser.getId());
    }

    /**
     * 查询全部数据，修改状态
     */
    @Override
    public List<ZkEquipmentMaintain> queryZkEquipmentMaintain() {
        return this.baseMapper.queryZkEquipmentMaintain();
    }

    /**
     * 保养柱状图PC端首页(根据保养周期统计数量)
     */
    @Override
    public List<Map<Integer, Integer>> pcCount() {
        return this.baseMapper.pcCount();
    }
}
